In this contribution, I expanded the code by Auren, creating a branched lightning and a lightning bolt generators, for ease of use, so the lightnings don’t need to be manually set.
The branched lightning draws a line with random offsets towards the destination point, meanwhile it creates smaller sublightnings that can be configured to end in a random place or go towards the destination.
The bolt detects collisions in a certain range with random raycasts and creates lightnings between the origin of the bolt and the collision point.
Two frames of the behaviour of the branching images.
A lightning bolt, detects collisions and creates branching lightnings in the collision points.